package com.weetop.aklyscan.presenter;

import android.app.Activity;

import com.blankj.utilcode.util.GsonUtils;
import com.weetop.aklyscan.base.mvp.BaseModel;
import com.weetop.aklyscan.base.mvp.BaseObserver;
import com.weetop.aklyscan.base.mvp.BasePresenter;
import com.weetop.aklyscan.bean.FittingInfo;
import com.weetop.aklyscan.bean.Into02Bean;
import com.weetop.aklyscan.bean.TransferBoxBean;
import com.weetop.aklyscan.bean.TypeInfo;
import com.weetop.aklyscan.bean.ZxListBean;
import com.weetop.aklyscan.view.ZxPeiJianView;

import org.json.JSONArray;

import java.util.ArrayList;
import java.util.List;

public class ZxPeiJianPresent extends BasePresenter<ZxPeiJianView> {

    public ZxPeiJianPresent(ZxPeiJianView baseView, Activity activity) {
        super(baseView, activity);
    }

    public void searchList(String code) {
        addDisposable(apiServer.scanTransferBox(code), new BaseObserver<BaseModel<TransferBoxBean>>(baseView) {
            @Override
            public void onSuccess(BaseModel<TransferBoxBean> o) {
                baseView.getSearchResultSuccess(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }

    public void scanFitting(String matter_code) {
        addDisposable(apiServer.Into07(matter_code), new BaseObserver<BaseModel<FittingInfo>>(baseView) {
            @Override
            public void onSuccess(BaseModel<FittingInfo> o) {
                baseView.getFittingInfoSuccess(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }

    public void saveZx(String barcode) {
        addDisposable(apiServer.into01(barcode), new BaseObserver<BaseModel<Object>>(baseView) {
            @Override
            public void onSuccess(BaseModel<Object> o) {
                baseView.saveZxSuccess(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }

    public void Into02(String barcode, JSONArray items) {
        addDisposable(apiServer.into02(barcode, items), new BaseObserver<BaseModel<Object>>(baseView) {
            @Override
            public void onSuccess(BaseModel<Object> o) {
                baseView.getInto02Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }

    public void Into07(String matter_code) {
        addDisposable(apiServer.Into07(matter_code), new BaseObserver<BaseModel<FittingInfo>>(baseView) {
            @Override
            public void onSuccess(BaseModel<FittingInfo> o) {
                baseView.getInto07Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }

    public void Into09(String orderId, String type, String barcode, JSONArray serial_code_items) {
        addDisposable(apiServer.Into09(orderId, type, barcode, serial_code_items), new BaseObserver<BaseModel<Object>>(baseView) {
            @Override
            public void onSuccess(BaseModel<Object> o) {
                baseView.getInto09Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }

    public void Into25(String order_type,String order_sn) {
        addDisposable(apiServer.Into25(order_type,order_sn), new BaseObserver<BaseModel<Object>>(baseView) {
            @Override
            public void onSuccess(BaseModel<Object> o) {
                baseView.getInto25Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.onDataError();
                }
            }
        });
    }

    public void Into18() {
        addDisposable(apiServer.Into18(), new BaseObserver<BaseModel<List<TypeInfo>>>(baseView) {
            @Override
            public void onSuccess(BaseModel<List<TypeInfo>> o) {
                baseView.getInto18Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }

    public void Into19(String order_type, String order_sn, String code, String num) {
        addDisposable(apiServer.Into19(order_type, order_sn, code, num), new BaseObserver<BaseModel<Object>>(baseView) {
            @Override
            public void onSuccess(BaseModel<Object> o) {
                baseView.getInto19Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }

    public void Into20(JSONArray items) {
        addDisposable(apiServer.Into20(items), new BaseObserver<BaseModel<Object>>(baseView) {
            @Override
            public void onSuccess(BaseModel<Object> o) {
                baseView.getInto20Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }

    public void Into21(JSONArray items, String order_sn) {
        addDisposable(apiServer.Into21(items, order_sn), new BaseObserver<BaseModel<Object>>(baseView) {
            @Override
            public void onSuccess(BaseModel<Object> o) {
                baseView.getInto21Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }

    public void Into22(String case_code) {
        addDisposable(apiServer.Into22(case_code), new BaseObserver<BaseModel<List<ZxListBean>>>(baseView) {
            @Override
            public void onSuccess(BaseModel<List<ZxListBean>> o) {
                baseView.getInto22Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }

    public void Into58(String order_type, String order_sn, String num, String matter_code) {
        addDisposable(apiServer.Into58(order_type, order_sn, num, matter_code), new BaseObserver<BaseModel<String>>(baseView) {
            @Override
            public void onSuccess(BaseModel<String> o) {
                baseView.getInto58Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }

}
